<?php
import( 'classes.core.View' );
import( 'classes.logic.Server' );
import( 'classes.logic.Project' );
/**
 *  Builds a select Box, to select Platforms of a Licencee
 *	@package		mv2.disposal.preparation
 *	@extends		Core_View
 *	@author			Dritan Latifi <dritan@gmail.com>
 *	@since			17.07.2007
 *	@version		0.1
 */
/**
 *	Builds a select Box, to select Platforms of a Licencee
 *	@package		mv2.disposal.preparation
 *	@extends		Core_View
 *	@author			Dritan Latifi <dritan@gmail.com>
 *	@since			17.07.2007
 *	@version		0.1
 */
class View_Panel_ProjectSelector extends Core_View
{
	function buildContent()
	{
		$session		= Framework_Krypton_Core_Registry::getStatic('session');
		$request		= Framework_Krypton_Core_Registry::getStatic( 'request' );
		$words			= $this->words['main']['selectProject'];
		
		$serverId		= $session->get( 'serverId' );
		$opt_servers	= array( 0 => '---------' );
		$logic		= new Logic_Server();
		$servers	= $logic->getServers( true );
		foreach( $servers as $id => $title )
			$opt_servers[$id]	= $title;
		$opt_servers['_selected'] = $serverId;

		$opt_projects	= array( 0 => '---------' );
//		if( $serverId )
//		{
			$logic		= new Logic_Project();
			$projects	= $logic->getProjects( true );

			foreach( $projects as $id => $title )
				$opt_projects[$id]	= $title;
			$opt_projects['_selected'] = $session->get( 'projectId' );
//		}

		$licencees		= Elements::Select( 'selectServer', $opt_servers, 'l', false, 'selectServer' );
		$platforms		= Elements::Select( 'selectProject', $opt_projects, 'l', false, 'selectProject' );
		$button			= Elements::Button( 'selectFrontend', $words['button'] );
		
		$ui['label_servers']	= Elements::Label( 'selectServer', $words['server'] );		
		$ui['label_projects']	= Elements::Label( 'selectProject', $words['project'] );		
		$ui['field_servers']	= Elements::Field( 'selectServer', $licencees );
		$ui['field_projects']	= Elements::Field( 'selectProject', $platforms );
		$ui['field_button']		= Elements::Field( '', $button );

		$ui['form']				= Elements::Form( 'selectProject', "?link=".$request->get('link')."&action=selectProject" );
		$ui['caption']			= Elements::TableCaption( $words['caption'], 'filter' );
		$ui['colgroup']			= Elements::ColumnGroup( $words['colgroup'] );
		$ui['heading']			= $words['heading'];
		return $this->loadTemplate( 'projects', $ui );
	}
}
?>